package com.adtec.base.cloud.baseservice.rbac.system.controller;

import com.adtec.base.cloud.baseservice.rbac.system.service.SysResetService;
import com.adtec.base.cloud.commons.exception.AjaxResponse;
import com.adtec.base.cloud.commons.exception.CustomExceptionType;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/sysreset")
@Tag(name = "sysreset", description = "一些工具")
public class SysResetController {
    @Resource
    private SysResetService sysResetService;


    @PostMapping(value = "/reset")
    @Operation(description = "重置服务器后台数据库")
    public AjaxResponse reset() {
        if ( sysResetService.reset()){
            return AjaxResponse.success("重置成功");
        }else{
            return AjaxResponse.error(CustomExceptionType.USER_INPUT_ERROR, "重置失败");
        }
    }

    @PostMapping(value = "/getScrewFile")
    @Operation(description = "生成数据库设计文档")
    public AjaxResponse getScrewFile() {
        sysResetService.getScrewFile();
        return AjaxResponse.success("生成成功");
    }
}
